package com.zlb.app.common.strategy.impl;

import com.zlb.app.common.properties.OssConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.InputStream;

/**
 * @Desc OSS上传策略
 * @Author zWX1367238
 * @Date 2024-08-16 11:05:53
 **/
@Service("ossUploadStrategyImpl")
public class OssUploadStrategyImpl extends AbstractUploadStrategyImpl {

    @Autowired
    private OssConfigProperties ossConfigProperties;

    @Override
    public Boolean exists(String filePath) {
        Boolean exists = true;
        // exists = getOssClient().doesObjectExist(ossConfigProperties.getBucketName(), filePath);
        return exists;
    }

    @Override
    public void upload(String path, String fileName, InputStream inputStream) {
        // getOssClient().putObject(ossConfigProperties.getBucketName(), path + fileName, inputStream);
    }

    @Override
    public String getFileAccessUrl(String filePath) {
        return ossConfigProperties.getUrl() + filePath;
    }

    // private OSS getOssClient() {
    //     return new OSSClientBuilder().build(ossConfigProperties.getEndpoint(), ossConfigProperties.getAccessKeyId(), ossConfigProperties.getAccessKeySecret());
    // }
}
